//
//  ViewController.m
//  HomeWork_0509
//
//  Created by dllo on 16/5/9.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "SimpleSlide.h"
#import "SimpleSide1.h"
#import "SimpleSlide2.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self createSlide];
    
    [self createSlide1];
    
    
    [self createSlide2];
    
    

    
}
- (void)createSlide{
    
    
    SimpleSlide *slide = [[SimpleSlide alloc]initWithFrame:CGRectMake(80, 200  , 300, 80)];
    
    [self.view addSubview:slide];
    [slide release];
    
    slide.minimumValue = 1;
    slide.maximumValue = 100;
    
    [slide addTarget:self action:@selector(handleSlide:) forControlEvents:UIControlEventValueChanged];
    
}


- (void)handleSlide:(SimpleSlide *)slide{
    
    self.view.alpha = slide.value / 100.0f;
    
    self.view.backgroundColor = [UIColor redColor];
    
    
    
}

- (void)createSlide1{
    
    
    SimpleSide1 *slide1 = [[SimpleSide1 alloc]initWithFrame:CGRectMake(80, 300 , 300, 80)];
    [self.view addSubview:slide1];
    [slide1 release];
    
    slide1.minimumValue = 1;
    slide1.maximumValue = 100;
    
    
    
    [slide1 addTarget:self action:@selector(handleSlide1:) forControlEvents:UIControlEventValueChanged];
    
}


- (void)handleSlide1:(SimpleSlide *)slide1{
    
    self.view.alpha = slide1.value / 100.0f;
    
    
     self.view.backgroundColor = [UIColor greenColor];
    
    
    
}

- (void)createSlide2{
    
    
    SimpleSlide2 *slide2 = [[SimpleSlide2 alloc]initWithFrame:CGRectMake(80, 400 , 300, 80)];
    [self.view addSubview:slide2];
    [slide2 release];
    
    slide2.minimumValue = 1;
    slide2.maximumValue = 100;
    
    
    
    [slide2 addTarget:self action:@selector(handleSlide2:) forControlEvents:UIControlEventValueChanged];
    [UIColor colorWithRed:arc4random() % 1 / 255.f green:arc4random() %1 / 255.f blue:arc4random() % 256 / 255.f alpha:1];
}


- (void)handleSlide2:(SimpleSlide2 *)slide2{
    
    
    self.view.alpha = slide2.value / 100.0f;
    
    self.view.backgroundColor = [UIColor blackColor];
    
    
}







@end
